<!--
 * @Description: DOM
 * @Author: admin
 * @Date: 2021-06-09 09:04:09
 * @LastEditors: admin
 * @LastEditTime: 2021-06-09 09:24:35
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>DOM测试</title>

</head>

<body>
  <div class="myDIv">
    父元素
    <div id="id1">子1</div>
    <div id="id2">子2</div>
    <!-- <div id="id3">子3</div> -->
  </div>
</body>
<script>
  // console.log(document.documentElement);
  console.log(document.body);
  // console.log(document.title);
  var a = document.getElementById("id3");
  console.log(a);
  a.setAttribute("className", "id3Class");
  var p = document.createElement('p');
  p.setAttribute('class', 'pClass')
  a.appendChild(p)
</script>

</html>